package com.njupt.wuaiagent.tools;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;

import java.io.IOException;

/**
 * @Author: wujiaming
 * @CreateTime: 2025/5/20 15:45
 * @Description: 网页抓取工具
 * @Version: 1.0
 */


public class WebScrapingTool {


    @Tool(description = "Scrap the content a web page")
    public String scrapWebPage(@ToolParam(description = "URL of the page to scrape") String url){

        Document document = null;
        try {
            document = Jsoup.connect(url).get();
            return document.html();
        } catch (IOException e) {
            return "Error scraping web page:" + e.getMessage();
        }

    }
}
